typedef struct
{
    int data[100];  //因为题目说最大push调用一百次
    int top;
    int bottom;
}Stack;

Stack *stackCreat()
{
    Stack *s=(Stack *)malloc(sizeof(Stack));
    if(s==NULL) //分配失败
        return 0;
    s->bottom=s->top=0;
    return s;
}

void stackPush(Stack *s,int num)
{
    s->data[s->top++]=num;
}

int stackPop(Stack *s)
{
    if(s->top!=s->bottom)   //如果栈不为空
    {
        int num=s->data[s->top-1];
        s->top--;
        return num;
    }
    else
        return 0;
    
}

void stack_Turn(Stack *p,Stack *q)
{
    while(p->top!=0)
    {
        stackPush(q,p->data[p->top-1]);
        p->top--;
    }
}

typedef struct {
    Stack *enter;
    Stack *out;

} MyQueue;


MyQueue* myQueueCreate()
{
    Stack *enter;
    Stack *out;
    enter=stackCreat();
    out=stackCreat();
    MyQueue *q=(MyQueue *)malloc(sizeof(MyQueue));
    q->enter=enter;
    q->out=out;
    return q;
}

void myQueuePush(MyQueue* obj, int x)
{
    stackPush(obj->enter,x);
}

int myQueuePop(MyQueue* obj)
{
    stack_Turn(obj->enter,obj->out);
    int num=stackPop(obj->out);
    stack_Turn(obj->out,obj->enter);
    return num;
}

int myQueuePeek(MyQueue* obj)
{
    int num=obj->enter->data[obj->enter->bottom];
    return  num;
}

bool myQueueEmpty(MyQueue* obj)
{
    if(obj->enter->top==obj->enter->bottom)
        return true;
    return false;
}

void myQueueFree(MyQueue* obj)
{
    free(obj->enter);
    free(obj->out);
}

/**
 * Your MyQueue struct will be instantiated and called as such:
 * MyQueue* obj = myQueueCreate();
 * myQueuePush(obj, x);
 
 * int param_2 = myQueuePop(obj);
 
 * int param_3 = myQueuePeek(obj);
 
 * bool param_4 = myQueueEmpty(obj);
 
 * myQueueFree(obj);
*/